<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const p1 = new Promise((resolve, reject) => {
        const age = +prompt("age?");
        if (age < 1 || age > 120) {
          reject(new Error("age error"));
        } else {
          resolve("right");
        }
      });
      // p1.then().catch();
      async function fn() {
        try {
          console.log(await p1);
        } catch (error) {
          console.log(error.message);
        }
      }
      fn();
    </script>
  </body>
</html>
